package com.carepad.dao;

import com.carepad.entity.Vital;
import com.carepad.entity.VitalExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

public interface VitalMapper {
	

	int countByExample(VitalExample example);

	int deleteByExample(VitalExample example);

	int deleteByPrimaryKey(Integer uid);

	int insert(Vital record);

	int insertSelective(Vital record);

	List<Vital> selectByExample(VitalExample example);
	
	Vital selectByPrimaryKey(Integer uid);

	int updateByExampleSelective(@Param("record") Vital record,	@Param("example") VitalExample example);

	int updateByExample(@Param("record") Vital record, @Param("example") VitalExample example);

	int updateByPrimaryKeySelective(Vital record);

	int updateByPrimaryKey(Vital record);

	int insertWithoutId(Vital record);

	@Select("SELECT t1.* FROM tbl_vital t1 " +
			"WHERE t1.HCS_ID = #{hcsId} " +
			"AND t1.EXECUTION_DATE = STR_TO_DATE(#{date}, '%m/%d/%Y') " +
			"AND t1.ACTION_TIME_FROM = (SELECT MAX(t2.ACTION_TIME_FROM) " +
			"FROM tbl_vital t2 " +
			"WHERE t2.HCS_ID = #{hcsId} " +
			"AND t2.EXECUTION_DATE = STR_TO_DATE(#{date}, '%m/%d/%Y'))")
	@ResultMap("BaseResultMap")
	Vital findByHcsIdandDate(@Param("hcsId") String hcsId, @Param("date") String date);
}